package git.soulbgm.security.constant;

/**
 * Security使用常数
 *
 * @author 贺瑞杰
 * @date 2021/01/07
 */
public final class SecurityConstants {

    /**
     * 前端需要传递的用户名参数名称
     */
    public static final String USERNAME_PARAMETER = "username";

    /**
     * 前端需要传递的密码参数名称
     */
    public static final String PASSWORD_PARAMETER = "password";

    /**
     * 登录处理的URL
     */
    public final static String LOGIN_PROCESSING_URL = "/login";

    /**
     * 登录相关过滤的url
     */
    public final static String[] LOGIN_ANT_PATTERNS = {"/login", "/registered"};

    /**
     * 出现错误跳转的url
     */
    public final static String[] ERROR_URL = {"/error"};

    /**
     * swagger过滤的url
     */
    public final static String[] SWAGGER_ANT_PATTERNS = {"/swagger-ui.html", "/webjars/**/**", "/swagger-resources/**/**", "/v2/**/**", "/api"};

    /**
     * druid过滤的url
     */
    public final static String[] DRUID_ANT_PATTERNS = {"/druid/**/**"};

    /**
     * 最大的登录失败次数
     */
    public static final int MAX_LOGIN_FAILURE_COUNT = 5;

    /**
     * 登录失败锁定持续时间(单位:秒)
     */
    public static final int LOGIN_FAILURE_LOCK_DURATION = 60;

    /**
     * 登录失败计数统计持续时间(单位:分钟)
     */
    public static final int LOGIN_FAILURE_COUNT_DURATION = 60;

    /**
     * 登录失败次数记录的Key前缀
     */
    public static final String KEY_PREFIX_LOGIN_FAILURE = "login:failure:";

    /**
     * 登录失败次数过多锁定的账号的Key前缀
     */
    public static final String KEY_PREFIX_LOGIN_LOCK = "login:lock:";

    /**
     * 登录方式 cookie
     */
    public static final Integer LOGIN_MODE_COOKIE = 1;

    /**
     * 登录方式 token
     */
    public static final Integer LOGIN_MODE_TOKEN = 2;

    /**
     * 登录用户 redis key前缀
     */
    public static final String LOGIN_TOKEN_KEY = "login:tokens:";

    /**
     * 在线用户 redis key前缀 key online:user:用户名 value Map (key:token value:ip)
     */
    public static final String ONLINE_USER_KEY = "online:user:";

    /**
     * 令牌
     */
    public static final String TOKEN = "token";

    /**
     * 令牌前缀
     */
    public static final String TOKEN_PREFIX = "Bearer ";

    /**
     * 令牌前缀
     */
    public static final String LOGIN_USER_KEY = "login_user_key";

}
